package io.renren.modules.skate.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import io.renren.common.exception.RenException;
import io.renren.modules.nuaa.dto.TCertificateDTO;
import io.renren.modules.nuaa.entity.TCategoryEntity;
import io.renren.modules.nuaa.excel.TCertificateExcel;
import io.renren.modules.nuaa.service.TCategoryService;
import io.renren.modules.nuaa.service.TCertificateService;
import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.skate.dto.FClubDTO;
import io.renren.modules.skate.excel.FClubExcel;
import io.renren.modules.skate.service.FClubService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@Scope("prototype")
public class FClubListener extends AnalysisEventListener<FClubExcel> {

    @Autowired
    private FClubService clubService;

    @Override
    public void invoke(FClubExcel fClubExcel, AnalysisContext analysisContext) {

        FClubDTO fClubDTO = new FClubDTO();


        fClubDTO.setClubName(fClubExcel.getClubName());
        fClubDTO.setUsername(fClubExcel.getUsername());
        fClubDTO.setPhone(fClubExcel.getPhone());
        fClubDTO.setExpirationDate(fClubExcel.getExpirationDate());
        fClubDTO.setCreateDate(new Date());
        fClubDTO.setCreator(SecurityUser.getUserId().toString());
        fClubDTO.setUpdater(SecurityUser.getUserId().toString());
        fClubDTO.setUpdateDate(new Date());
        clubService.save(fClubDTO);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
